<?php
require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'autoload.php';

use payClass\Datebase;
use payClass\QRcode;
use payClass\pay\Config;

/**
 * 扫码支付
 */
class Scan
{
	public static function scanDo()
	{
		$db     = new Datebase();

		$config = new Config();

		$param  = $db->param();

		// 订单号
		$param['orderNumber'] = 'C' . time() . 'U' . $param['uid'];

		$param['paytype'] = Config::$folder.'-'.Config::$merchant;
		// 数据检测
		// $verifyRes = $db->verifyScan($param);

		// if ($verifyRes != 'Y') $db->ajaxReturn($verifyRes);

		$data = [
			'order_sn' => $param['orderNumber'],
			'money'    => sprintf("%.2f", $param['price']),
			'pay_type' => $param['scanType'],
		];

		$resArray = Config::addOrder($data);

		if ($resArray['code'] != '100') $db->ajaxReturn($resArray['msg']);
print_r($resArray);die;
		$db->ajaxReturn($resArray['data']['url']);
	}
}

Scan::scanDo();
